package com.hfzy.ihk.web.ivr;

import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Administrator on 2017/12/1.
 *
 * @author wws
 */
@SpringBootApplication(exclude = {
        RedisAutoConfiguration.class,
        KafkaAutoConfiguration.class,
        SecurityAutoConfiguration.class
})
@ComponentScan(basePackages = "com.hfzy.ihk")
@EnableDubbo(scanBasePackages = "com.hfzy.ihk.web.ivr.service.impl")
@EnableScheduling
@EnableAsync
public class Application {


    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
//
    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return (String... args) -> {
//            if("true".equals(aliyun)) {
//                AliyunMsgInti.intiVoiceRTASRReport();//初始化接受asr 长连接
//                AliyunMsgInti.intiVoiceCallReport();
//            }
            //初始化http连接池
//            HttpClientUtils.init();
        };
    }

    @Bean
    public RestTemplate restTemplate(ClientHttpRequestFactory factory){
        return new RestTemplate(factory);
    }

    @Bean
    public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setConnectTimeout(15000);
        factory.setReadTimeout(5000);
        return factory;
    }



}
